let loaderUtils = require('loader-utils');
let mime = require('mime');

function loader(source) {
    let option = loaderUtils.getOptions(this);
    if (source.length <= option.limit && limit) {
        // mime.getType可以获取文件类型
        return `module.exports = ${mime.getType(this.resourcePath)};base64,${source.toString('base64')}`
    } else {
        // 需要传递this
        return require('./file-loader').call(this, source)
    }
}

loader.raw = true;

module.exports = loader